//
//  WebViewController.m
//  mafengwo
//
//  Created by Mac on 16/4/17.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController ()

@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //浏览界面
    UIWebView *webV = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, KScreenW, KScreenH)];
    [self.view addSubview:webV];
    //浏览请求
    NSURLRequest *request = [NSURLRequest requestWithURL:_url];
    [webV loadRequest:request];

    //创建头部视图
    [self createHeadView];

}

//创建头部视图
-(void)createHeadView{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenW, 101)];
    //    view.backgroundColor = [UIColor whiteColor];
    view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"webView_bg.png"]];
    [self.view addSubview:view];

    //返回摁钮
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(10,101/2, 40, 40)];
    [button setImage:[UIImage imageNamed:@"webView_back.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:button];

    //头部视图名称
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(view.frame.size.width/2-50, 101/2, 100, 40)];
    label.textAlignment = NSTextAlignmentCenter;
    label.text = _viewTitle;
    label.font = [UIFont boldSystemFontOfSize:28];
//    label.font = [UIFont systemFontOfSize:28];

    label.textColor = [UIColor whiteColor];
    [view addSubview:label];
    
}

-(void)setUrl:(NSURL *)url{

    _url = url;
}
-(void)setViewTitle:(NSString *)viewTitle{
    _viewTitle = viewTitle;
}
//返回
-(void)backAction{

    [self dismissViewControllerAnimated:NO completion:nil];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
